<?php

namespace App\Http\Controllers\Api\O1\UserCenter\Paper;

use Illuminate\Http\Request;
use Biz\Jobs\SiteEmailSendJob;
use Biz\Services\Site\SitePaperService;
use Biz\Services\Site\SitePaperFullService;
use Biz\Requests\Site\StorePaperFullRequest;
use Biz\Requests\Site\UpdatePaperFullRequest;
use Biz\Resources\Site\SitePaperFullResource;
use Biz\Transformers\Site\PaperFullTransformer;
use Biz\Mailers\Site\SitePaperFullSubmissionMail;
use Lumen\Http\Resources\Json\DataResourceResponse;
use Biz\Transformers\Site\PaperTransformerCollection;
use Biz\Resources\Site\SitePaperFullResourceCollection;
use Laravel\Lumen\Routing\Controller as BaseController;

/**
 * PaperFullController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class FullController extends BaseController
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * @var mixed
     */
    protected $paperService;

    /**
     * PaperAbstractController constructor.
     *
     * @param SitePaperFullService $service
     * @param SitePaperService     $paperService
     */
    public function __construct(SitePaperFullService $service, SitePaperService $paperService)
    {
        $this->service      = $service;
        $this->paperService = $paperService;
    }

    /**
     * Display a listing of the resource.
     *
     * @param Request $request
     *
     * @return SitePaperFullResourceCollection
     */
    public function index(Request $request)
    {
        $results = $this->paperService->getUserPaperFullList($request);

        return new PaperTransformerCollection($results);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param StorePaperFullRequest $request
     * @param string                $paper_id
     *
     * @return \Illuminate\Http\Response
     */
    public function store(StorePaperFullRequest $request, string $paper_id)
    {
        $full = $this->service->store($request, $paper_id);

        // Send email
        $mail = new SitePaperFullSubmissionMail($full);
        dispatch(new SiteEmailSendJob($mail));

        return new PaperFullTransformer($full);
    }

//
//    /**
//     * Display the specified resource.
//     *
//     * @param string $paper_id
//     * @param string $full_id
//     *
//     * @return \Illuminate\Http\Response
//     */
//    public function show(string $paper_id, string $full_id)
//    {
//        $full = $this->service->show($paper_id, $full_id);
//
//        return new SitePaperFullResource($full);
//    }
//
//    /**
//     * Update the specified resource in storage.
//     *
//     * @param UpdatePaperFullRequest $request
//     * @param string                 $paper_id
//     * @param string                 $full_id
//     *
//     * @return \Illuminate\Http\Response
//     */
//    public function update(UpdatePaperFullRequest $request, string $paper_id, string $full_id)
//    {
//        $full = $this->service->edit($paper_id, $full_id, $request->all());
//
//        return new SitePaperFullResource($full);
//    }
//
//    /**
//     * Remove the specified resource from storage.
//     *
//     * @param string $paper_id
//     * @param string $full_id
//     *
//     * @return \Illuminate\Http\Response
//     */
//    public function destroy(string $paper_id, string $full_id)
//    {
//        $result = $this->service->remove($paper_id, $full_id);
//
//        return new DataResourceResponse($result);
//    }
}
